import React, { Component } from 'react'
import { withRouter } from 'react-router-dom'

 class Header extends Component {

  goForward = () => {
    this.props.history.goForward()
  }

  goBack = () => {
    this.props.history.goBack()
  }
  render() {
    return (
        <div className="row">
          
        <div className="col-xs-offset-2 col-xs-8">
          
            <div className="page-header">
              <h2>React Router Demo</h2>
              <button onClick={this.goForward}>前进</button>
                &nbsp;
              <button onClick={this.goBack}>后退</button>
            </div>
        </div>
    </div>
    )
  }
}

// withRouter 经过withRouter的加工, 让一般组件具备路由组件所特有的api 
export default withRouter(Header)
